Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

459
Views
La función de propiedad no existe en el tipo "AppComponent"

estamos tratando de insertar elementos de matriz en datos (matriz). Soy un principiante en angular y mecanografiado y estoy trabajando en un proyecto de calculadora de fórmulas. He intentado convertir javascript a mecanografiado y obtengo estos errores. Estoy atascado si necesito hacer alguna importación o exportación para que mi función funcione o me falta algo en el código. Primero, creé la calculadora de fórmulas. El código funciona perfectamente en javascript, pero el problema comenzó cuando convertí javascript a mecanografiado para mi proyecto angular. Estoy usando Angular12.

------ERROR-------

 Error: src/app/app.component.html:27:56 - error TS2339: Property 'add_element' does not exist on type 'AppComponent'. 27 <input type=button id="element" value='ADDDD' (click)='add_element()' src/app/app.component.ts:6:16 ----App.Comonent.html----- <input type=text id='result'> <input type=button id="element" value='ADDDD' (click)='add_element()'> <div id=disp></div> ------App.component.ts------ declare var require:any import { Component, OnInit } from '@angular/core'; @Component({ selector: 'app-add', templateUrl: './add.component.html', styleUrls: ['./add.component.css'] }) export class AddComponent implements OnInit { constructor() { } ngOnInit(): void { } // data:any = new Array(); // creating array // data1 = new Array(); addElement = function add_element():any{ var data:any = new Array(); // creating array data.push((document.getElementById('result') as HTMLInputElement).value); // adding element to array ((document.getElementById('result') as HTMLInputElement).value)=''; // Making the text box blank let element:any = function disp() // displaying the array elements { let element1:any = function disp(row1:number,col1:number):any{ var str=''; str = 'total number of elements in data array : ' + data.length + '<br>'; let n = row1 * col1; if(data.length<= n ){ for (var i=0;i<data.length;i++) { str += i + ':'+data[i] + "<br >"; // adding each element with key number to variabl } (document.getElementById('disp')as HTMLInputElement).innerHTML=str; // Display the elements of the array } } } } add_element() { throw new Error('Function not implemented.'); } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Debe usar el mismo nombre del método en la plantilla y la clase. Por ejemplo:

 <input type=button id="element" value='ADDDD' (click)='addElement()'>
 import { Component, OnInit } from '@angular/core'; @Component({ selector: 'app-add', templateUrl: './add.component.html', styleUrls: ['./add.component.css'] }) export class AddComponent implements OnInit { constructor() { } ngOnInit(): void { } addElement(): void { // your code here } }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!